#pragma once

#include <FixBuffer.h>
#include <string>

namespace AsyncLogger {

	class LogStream {
		using Buffer = detail::FixBuffer<detail::kSmallBuffer>;
	public:
		LogStream& operator<<(const std::string& logline);
		LogStream& operator<<(const char* logline);
		LogStream& operator<<(const unsigned char* logline);
		LogStream& operator<<(bool logline);
		LogStream& operator<<(char logline);
		LogStream& operator<<(long logline);
		LogStream& operator<<(unsigned long logline);
		LogStream& operator<<(long long logline);
		LogStream& operator<<(unsigned long long logline);
		LogStream& operator<<(int logline);
		LogStream& operator<<(unsigned int logline);
		LogStream& operator<<(double logline);
		LogStream& operator<<(float logline);

		char* data() { return buffer_.data(); }

		size_t length() { return buffer_.length(); }

	private:
		/// <summary>
		/// 格式化的功能没有像muduo那样子加上K、M、G等单位，可能需要优化
		/// </summary>
		/// <typeparam name="Num"></typeparam>
		/// <param name="num"></param>
		/// <returns></returns>
		template<typename Num>
		std::string numToString(Num num) {

			return std::to_string(num);
		}

	private:
		Buffer buffer_;
	};

}